<extend name="Public:base" />

<block name="content">

    <div class="row">
        <div class="col-xs-12">
            <div class="table-responsive">
                    <table class="table table-striped table-bordered table-hover" id="mytable">

                        <thead>
                        <tr>
                            <th>公式</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td colspan="2"><b>当星级< 20颗时，佣金公式：</b></td>
                        </tr>

                        <volist name="data" id="da" key="k">
                         <tr>
                             <td> <label onclick="change({$da.id})"><input type="radio"  name="as" value="1" {$da['status']==2?"checked='checked'":''}/>公式{$k}：（{$da.constant}-{$da.variable}X）%*维修金额</label></td>
                             <td><button  style="{$update==1?'':'display: none'}" onclick="showdiv({$k})" class="btn btn-xs btn-info radius5">编辑</button></td>
                         </tr>
                            <div id="div{$k}" style="display:none;background: #FFF;width: 700px;height: 250px;position:absolute;border:solid 1px yellow;left: 183px;top: 100px" >
                                <div style="margin: 111px">公式{$k}：（<input id="con{$k}" value="{$da.constant}">-<input id="var{$k}" value="{$da.variable}">X）%*维修金额
                                 <div style="margin: 18px 173px">
                                     <input class="btn btn-primary btn-sm radius5" type="button" onclick="update({$k},{$da.id})" value="保存">
                                     <input class="btn btn-primary btn-sm radius5" type="button" value="返回" onclick="yin({$k})">
                                 </div>
                                </div>
                            </div>
                        </volist>
                        <tr>
                            <td colspan="2">
                                <b>当星级=20颗时,佣金或奖励=0：</b>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <b>当星级>20颗时，奖励公式：</b>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <label><input type="radio"  name="status" value="1" checked='checked'}/>公式1：（X-20）*维修金额/{$money.money}
                                </label>
                            </td>
                            <td><button  style="{$update==1?'':'display: none'}" onclick="showdiv('abc')" class="btn btn-xs btn-info radius5">编辑</button></td>
                        </tr>
                        <div id="divabc" style="display:none;background: #FFF;width: 700px;height: 250px;position:absolute;border:solid 1px yellow;left: 183px;top: 100px" >
                            <div style="margin: 111px">公式1：公式1：（X-20）*维修金额/<input id="money" value="{$money.money}">
                                <div style="margin: 18px 173px">
                                    <input class="btn btn-primary btn-sm radius5" type="button" onclick="updatemoney()" value="保存">
                                    <input class="btn btn-primary btn-sm radius5" type="button" value="返回" onclick="yin('abc')">
                                </div>
                            </div>
                        </div>

                        </tbody>

                    </table>
            </div>
        </div>
    </div>
</block>
<block name="javascript">
    <script>
        function update(k,id){
            var con=$('#con'+k).val()
            var va=$('#var'+k).val()
            if(isNaN(con)){
                alert("输入的必须为数字")
                return false;
            }
            url="{:U('CommentManage/update')}"
            $.ajax({
                type:'post',
                url:url,
        data:{
            con:con,
                    va:va,
                    id:id,
        },
        success:function(data){
            alert("保存成功")
        }
        })
        };
        function yin(k){
            $("#div"+k).hide()
            location.reload()
        };
        function showdiv(k){
            $("#div"+k).show()
        };
        function updatemoney(){
              var money=$("#money").val()
            url="{:U('CommentManage/updatemoney')}"
            $.ajax({
                type:'post',
                url:url,
                data:{
                    money:money
                },
                success:function(data){
                    alert("保存成功")
                }
            })
        };
        function change(k){
            url="{:U('CommentManage/change')}";
            $.ajax({
                type:'post',
                url:url,
                data:{
                    id:k
                },
                success:function(data){
                    if(data=='yes'){

                    }else{
                        alert('出错了')
                    }
                }
            })
        }
    </script>
    <script>
        var le=0;
        $(function(){
            $("#search").click(function () {
                var url = $(this).attr('url');
                var query = $('.search-form').find('input,select').serialize();
                query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
                query = query.replace(/^&/g, '');
                if (url.indexOf('?') > 0) {
                    url += '&' + query;
                } else {
                    url += '?' + query;
                }
                window.location.href = url;
            });

            $("#all").click(function() {
                console.log(this.checked)
                $(".che").attr("checked",this.checked);
            })
        });
        $('#delete').click(function(){
            console.log( $('.che').length)
            for(var i=0;i<$('.che').length;i++){
                if($('.che')[i].checked==true){
                    le+=1;
                }
            }
            if(le==0){
                alert('选择不能为空');
                return false;
            }
        });
        $('.che').click(function(){
            console.log(this.checked)
        })
    </script>
</block>